<template>
  <div class="app-container">
<!--    不在使用-->
    <el-form ref="elFormSetting" :model="formSettingData" :rules="rules" size="medium" label-width="120px">
      <el-form-item label="上级国标地址" prop="sip_server_host">
        <el-input
          v-model="formSettingData.sip_server_host"
          placeholder="请输入上级国标服务器地址"
          :maxlength="256"
          show-word-limit
          clearable
          prefix-icon="el-icon-mobile"
          :style="{width: '100%'}"
        />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { load } from '@/api/setting'
export default {
  name: 'Setting',
  components: {},
  props: [],
  data() {
    return {
      formSettingData: {
        upper_host: undefined,
        upper_port: undefined,
        upper_realm: undefined,
        upper_password: undefined,
        keep_alive_second: 60
      },
      loading: false,
      rules: {
        upper_host: [{ required: true, message: '请输入信令服务器地址', trigger: 'blur' }],
        upper_port: [{ required: true, message: '请输入信令服务端口', trigger: 'blur' }],
        upper_realm: [{ required: true, message: '请输入服务器域', trigger: 'blur' }],
        upper_password: [{ required: true, message: '请输入验证密码', trigger: 'blur' }],
        keep_alive_second: [{ required: true, message: '请输入心跳时间', trigger: 'blur' }]
      }
    }
  },
  computed: {},
  watch: {},
  created() {
    this.fetchData()
  },
  mounted() {},
  methods: {
    fetchData() {
      load().then(ret => {
        console.log('ret.data', ret.data)
        this.formSettingData = ret.data
      })
    },
    submitForm() {
      this.$refs['elFormSetting'].validate(valid => {
        if (valid) {
          this.loading = true
          this.$store.dispatch('setting/cascadeupsave', this.formSettingData).then(() => {
            // this.$router.push({ path: this.redirect || '/' })
            this.loading = false
          }).catch((err) => {
            console.error(err)
            this.loading = false
          })
        } else {
          this.loading = false
        }
      })
    },
    resetForm() {
      this.$refs['elFormSetting'].resetFields()
    }
  }
}
</script>

<style>
</style>
